package com.serviceprovider.business.module.user.model.forms;

//~--- non-JDK imports --------------------------------------------------------

import com.serviceprovider.business.module.admin.address.model.Address;
import com.serviceprovider.business.module.admin.role.model.Role;
import com.serviceprovider.business.module.admin.user.services.dao.impl.UserService;
import com.serviceprovider.business.module.common.Page;
import com.serviceprovider.business.module.user.model.impl.User;

import org.springmodules.validation.bean.conf.loader.annotation.handler.Email;
import org.springmodules.validation.bean.conf.loader.annotation.handler.Length;
import org.springmodules.validation.bean.conf.loader.annotation.handler.NotBlank;
import org.springmodules.validation.bean.conf.loader.annotation.handler.RegExp;

//~--- JDK imports ------------------------------------------------------------

import java.util.Date;
import java.util.List;

public class EditUserForm {
    @RegExp(
        "(^$|^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\\-+)|([A-Za-z0-9]+\\.+)|([A-Za-z0-9]+\\++))*[A-Za-z0-9]+@((\\w+\\-+)|(\\w+\\.))*\\w{1,63}\\.[a-zA-Z]{2,6}$)")
    private String  alternateEmail;
    private int     bonusTestAmount;
    private Address businessAddress;
    private String  businessFein;
    private String  businessName;
    private Integer checkPrintingBy;

    /** ContactAddress's city */
    private String  city;
    @NotBlank
    @Length(min = 6)
    private String  confirmPassword;
    private Address contactAddress;

    /** ContactAddress's country */
    private String  country;
    private Date    createdOn;
    private User    currentUser;
    private boolean deleted;
    private Integer efin;
    @Email
    private String  email;
    private boolean enabled;

    /** custom fee in Preferences class */
    private Integer       fee;
    @NotBlank
    private String        firstName;
    private int           id;
    @NotBlank
    private String        lastName;
    private User          level1User;
    private int           level1UserId;
    private String        milddleName;
    private Integer       orderApproval;
    private Integer       ownerSsn;
    @NotBlank
    @Length(min = 6)
    private String        password;
    private int           prefMessageNotifyAlert;
    private int           prefMessageNotifyType;
    private Integer       ptin;
    private int           refererId;
    private Role          role;
    private int           roleId;
    private Address       shippingAddress;
    private Integer       ssn;
    private List<Integer> usersId;
    private Page<User>    usersList;
    private List<Integer> usersListActivated;
    private List<Integer> usersListDeleted;

    /** ContactAddress's zip */
    private String zip;

    public EditUserForm() {
        initFields();
    }

    public EditUserForm(User user) {
        if (user == null) {
            initFields();

            return;
        }

        this.id                     = user.getId();
        this.email                  = user.getEmail();
        this.alternateEmail         = user.getAlternateEmail();
        this.password               = user.getPassword();
        this.enabled                = user.isEnabled();
        this.deleted                = user.isDeleted();
        this.refererId              = user.getRefererId();
        this.firstName              = user.getFirstName();
        this.milddleName            = user.getMilddleName();
        this.lastName               = user.getLastName();
        this.efin                   = user.getEfin();
        this.ssn                    = user.getSsn();
        this.ptin                   = user.getPtin();
        this.checkPrintingBy        = user.getCheckPrintingBy();
        this.orderApproval          = user.getOrderApproval();
        this.businessName           = user.getBusinessName();
        this.businessFein           = user.getBusinessFein();
        this.ownerSsn               = user.getOwnerSsn();
        this.prefMessageNotifyType  = user.getPrefMessageNotifyType();
        this.prefMessageNotifyAlert = user.getPrefMessageNotifyAlert();
        this.bonusTestAmount        = user.getBonusTestAmount();
        this.createdOn              = user.getCreatedOn();
        this.role                   = (user.getRole() == null)
                                      ? new Role()
                                      : user.getRole();
        this.level1User             = (user.getLevel1User() == null)
                                      ? new User()
                                      : user.getLevel1User();
        this.contactAddress         = (user.getContactAddress() == null)
                                      ? new Address()
                                      : user.getContactAddress();
        this.businessAddress        = (user.getBusinessAddress() == null)
                                      ? new Address()
                                      : user.getBusinessAddress();
        this.shippingAddress        = (user.getShippingAddress() == null)
                                      ? new Address()
                                      : user.getShippingAddress();
    }

    private void initFields() {
        this.contactAddress  = new Address();
        this.businessAddress = new Address();
        this.shippingAddress = new Address();
        this.role            = new Role();
        this.level1User      = new User();
        this.enabled         = true;
        this.email           = "example@gmail.com";
        this.currentUser     = new User();
    }

    public void setRoleId(int roleId) {
        this.roleId = roleId;
    }

    public int getRoleId() {
        return roleId;
    }

    public Page<User> getUsersList() {
        return usersList;
    }

    public void setUsersList(Page<User> usersList) {
        this.usersList = usersList;
    }

    public int getLevel1UserId() {
        return level1UserId;
    }

    public void setLevel1UserId(int level1UserId) {
        this.level1UserId = level1UserId;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getAlternateEmail() {
        return alternateEmail;
    }

    public void setAlternateEmail(String alternateEmail) {
        this.alternateEmail = alternateEmail;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getConfirmPassword() {
        return confirmPassword;
    }

    public void setConfirmPassword(String confirmPassword) {
        this.confirmPassword = confirmPassword;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public Integer getEfin() {
        return efin;
    }

    public void setEfin(Integer efin) {
        this.efin = efin;
    }

    public List<Integer> getUsersListActivated() {
        return usersListActivated;
    }

    public void setUsersListActivated(List<Integer> usersListActivated) {
        this.usersListActivated = usersListActivated;
    }

    public List<Integer> getUsersListDeleted() {
        return usersListDeleted;
    }

    public void setUsersListDeleted(List<Integer> usersListDeleted) {
        this.usersListDeleted = usersListDeleted;
    }

    public List<Integer> getUsersId() {
        return usersId;
    }

    public void setUsersId(List<Integer> usersId) {
        this.usersId = usersId;
    }

    public Integer getSsn() {
        return ssn;
    }

    public void setSsn(Integer ssn) {
        this.ssn = ssn;
    }

    public void setPtin(Integer ptin) {
        this.ptin = ptin;
    }

    public Integer getPtin() {
        return ptin;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getZip() {
        return zip;
    }

    public void setZip(String zip) {
        this.zip = zip;
    }

    public boolean isDeleted() {
        return deleted;
    }

    public void setDeleted(boolean deleted) {
        this.deleted = deleted;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    public User getCurrentUser() {
        return currentUser;
    }

    public void setCurrentUser(User currentUser) {
        this.currentUser = currentUser;
    }

    public int getRefererId() {
        return refererId;
    }

    public void setRefererId(int refererId) {
        this.refererId = refererId;
    }

    public User getLevel1User() {
        return level1User;
    }

    public void setLevel1User(User level1User) {
        this.level1User = level1User;
    }

    public String getMilddleName() {
        return milddleName;
    }

    public void setMilddleName(String milddleName) {
        this.milddleName = milddleName;
    }

    public String getBusinessFein() {
        return businessFein;
    }

    public void setBusinessFein(String businessFein) {
        this.businessFein = businessFein;
    }

    public String getBusinessName() {
        return businessName;
    }

    public void setBusinessName(String businessName) {
        this.businessName = businessName;
    }

    public Integer getOwnerSsn() {
        return ownerSsn;
    }

    public void setOwnerSsn(Integer ownerSsn) {
        this.ownerSsn = ownerSsn;
    }

    public Address getContactAddress() {
        return contactAddress;
    }

    public void setContactAddress(Address contactAddress) {
        this.contactAddress = contactAddress;
    }

    public Address getBusinessAddress() {
        return businessAddress;
    }

    public void setBusinessAddress(Address businessAddress) {
        this.businessAddress = businessAddress;
    }

    public Address getShippingAddress() {
        return shippingAddress;
    }

    public void setShippingAddress(Address shippingAddress) {
        this.shippingAddress = shippingAddress;
    }

    public int getPrefMessageNotifyType() {
        return prefMessageNotifyType;
    }

    public void setPrefMessageNotifyType(int prefMessageNotifyType) {
        this.prefMessageNotifyType = prefMessageNotifyType;
    }

    public int getPrefMessageNotifyAlert() {
        return prefMessageNotifyAlert;
    }

    public void setPrefMessageNotifyAlert(int prefMessageNotifyAlert) {
        this.prefMessageNotifyAlert = prefMessageNotifyAlert;
    }

    public int getBonusTestAmount() {
        return bonusTestAmount;
    }

    public void setBonusTestAmount(int bonusTestAmount) {
        this.bonusTestAmount = bonusTestAmount;
    }

    public Date getCreatedOn() {
        return createdOn;
    }

    public void setCreatedOn(Date createdOn) {
        this.createdOn = createdOn;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public Integer getFee() {
        return fee;
    }

    public void setFee(Integer fee) {
        this.fee = fee;
    }

    public Integer getOrderApproval() {
        return orderApproval;
    }

    public void setOrderApproval(Integer orderApproval) {
        this.orderApproval = orderApproval;
    }

    public Integer getCheckPrintingBy() {
        return checkPrintingBy;
    }

    public void setCheckPrintingBy(Integer checkPrintingBy) {
        this.checkPrintingBy = checkPrintingBy;
    }
}



